package com.atguigu.gmall.product;

import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient1;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;
import org.springframework.util.ClassUtils;


public class FastDFSDemo {
    //文件上传
    public static void main(String[] args) throws Exception {
        String path = ClassUtils.getDefaultClassLoader().getResource("fdfs_client.conf").getPath();
        System.out.println(path);
        //0.设置配置文件的位置进行读取   init IO流 读取配置文件 必须是绝对路径
        ClientGlobal.init(path);
        //1.连接Tracker跟踪器
        TrackerClient trackerClient = new TrackerClient();
        //2.返回存储节点的地址
        TrackerServer trackerServer = trackerClient.getConnection();
        //3.连接存储节点
        StorageClient1 storageClient1 = new StorageClient1(trackerServer,null);
        //4.上传文件
        String fileId = storageClient1.upload_appender_file1("C:\\Users\\19648\\Pictures\\Camera Roll\\wallhaven-j5gkxq.png",
                "png",
                null);
        System.out.println(fileId);
    }
}
